﻿using System.Linq;
using RuTracker.Interface;
using RuTrackerLib.ServiceAttibutes;

namespace RuTrackerLib.Tracker
{
    [PerCallService]
    public class TrackerInfoRepository : ITrackerInfoRepository 
    {
       private readonly DataClassesDataContext _context;

        public TrackerInfoRepository(IDbLayerSettings settings)
            : this(new DataClassesDataContext(settings.ConnectionString))
        {
        }

        protected TrackerInfoRepository(DataClassesDataContext context)
        {
            _context = context;
        }

        public TrackerInformation GetTrackerInfo(string trackerName)
        {
            return _context.TrackerInformations.First(t => t.Name == trackerName);
        }
    }
}
